package dialog;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import net.ck.hzq.R;

import Utils.ScreenUtil;

public class DirectionalAllocationResDialog extends BaseDialog {

    private OnConfirmListener2 mOnConfirmListener;

    public static DirectionalAllocationResDialog newInstance() {
        DirectionalAllocationResDialog dialog = new DirectionalAllocationResDialog();
//        Bundle arguments = new Bundle();
//        arguments.putString("partnerName", partnerName);
//        dialog.setArguments(arguments);
        return dialog;
    }

    public void setConfirmListener(OnConfirmListener2 listener) {
        mOnConfirmListener = listener;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
            savedInstanceState) {
        if (getDialog() != null && getDialog().getWindow() != null) {
            getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
        return inflater.inflate(R.layout.dialog_directional_allocationres, container, false);
    }

    @Override
    public void onStart() {
        super.onStart();
        if (getDialog() != null && getDialog().getWindow() != null) {
            getDialog().getWindow().setLayout(ScreenUtil.dip2px(300), ScreenUtil.dip2px(120));
        }
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        view.findViewById(R.id.confirm).setOnClickListener(v -> {
            if (mOnConfirmListener != null) {
                mOnConfirmListener.onConfirm();
            }
        });
//        view.findViewById(R.id.cancel).setOnClickListener(v -> dismiss());


    }
}
